package com.atguigu.gmall.activity.controller;

import com.atguigu.gmall.activity.pojo.UserRecode;
import com.atguigu.gmall.activity.service.SeckillGoodsService;
import com.atguigu.gmall.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/seckill/order")
public class SeckillOrderController {


    @Autowired
    private SeckillGoodsService seckillGoodsService;

    /**
     * 秒杀下单
     * @param skuId
     * @param time
     * @return
     */
    @GetMapping(value = "/add")
    public Result addSeckillOrder(String skuId,String time){
        // 将用户id写死,便于测试
        String userId = "1";
        UserRecode userRecode = seckillGoodsService.addOrder(time, skuId, userId);
        return Result.ok(userRecode);
    }

    /**
     * 查询用户的排队信息
     * @return
     */
    @GetMapping(value = "/getRecode")
    public Result getUserRecode(){
        // 将用户id写死,便于测试
        String userId = "1";
        UserRecode userRecode = seckillGoodsService.getUserRecode(userId);
        return Result.ok(userRecode);

    }
}
